home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 September / maximum-cd-2000-09.iso / Vampire the Masquerade / vampire_demo.exe / Codex.nob / WalkCycle.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  2.1 KB  |  70 lines

  1. public class WalkCycle extends Codex {
  2.    private int actorGuid;
  3.    private CodexActor actor;
  4.    private int numFrames;
  5.    private int currentFrame;
  6.    private int goalFrame;
  7.    private float[] pos = new float[3];
  8.    private float speed = 90.0F;
  9.  
  10.    public void beginscene(int clientGuid, int captureID) {
  11.       this.currentFrame = 0;
  12.       this.goalFrame = 1;
  13.       if (this.Init()) {
  14.          ((Codex)this).SetTimer(5.0F);
  15.       }
  16.  
  17.    }
  18.  
  19.    public void arrived(int thingGuid, int frameNum, int captureID) {
  20.       this.currentFrame = this.goalFrame;
  21.       if (++this.goalFrame >= this.numFrames) {
  22.          this.goalFrame = 0;
  23.       }
  24.  
  25.       this.pos = this.actor.GetFramePosition(this.goalFrame);
  26.       this.actor.SendActorToPos(this.pos, 90.0F);
  27.    }
  28.  
  29.    public void restore(int flags) {
  30.       this.goalFrame = CodexSequence.RestoreInt();
  31.       this.currentFrame = CodexSequence.RestoreInt();
  32.    }
  33.  
  34.    public void restored(int flags) {
  35.       ((Codex)this).KillTimer();
  36.       if (this.Init()) {
  37.          this.actor.SendActorToPos(this.pos, 90.0F);
  38.       }
  39.  
  40.    }
  41.  
  42.    public void save(int flags) {
  43.       CodexSequence.SaveInt(this.goalFrame);
  44.       CodexSequence.SaveInt(this.currentFrame);
  45.    }
  46.  
  47.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  48.       this.actor.SendActorToPos(this.pos, 90.0F);
  49.    }
  50.  
  51.    public boolean Init() {
  52.       this.actorGuid = ((Codex)this).GetClassThing();
  53.       if (!Codex.IsActorGuid(this.actorGuid)) {
  54.          CodexConsole.PrintError("No class thing in WalkCycle!");
  55.          return false;
  56.       } else {
  57.          this.actor = new CodexActor(this.actorGuid);
  58.          this.numFrames = this.actor.GetNumFrames();
  59.          if (this.numFrames == 0) {
  60.             CodexConsole.PrintError("Object w/o frames in WalkCycle!");
  61.             return false;
  62.          } else {
  63.             this.pos = this.actor.GetFramePosition(this.goalFrame);
  64.             this.actor.SetActorFlags(524288);
  65.             return true;
  66.          }
  67.       }
  68.    }
  69. }
  70.